import hashlib

from django.shortcuts import redirect


def pwd_encrypt(password):
    md5 = hashlib.md5()
    md5.update(password.encode())
    result = md5.hexdigest()
    return result

def seller_decorator(func):
    def inner(request, *args, **kwargs):
        username = request.session.get('username')
        nickname = request.session.get('nickname')
        if username and nickname:
            return func(request, *args, **kwargs)
        else:
            return redirect('/Seller/login')
    return inner